<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/pages/common/header.jsp"%>
 <script type="text/javascript" src="<%=request.getContextPath() %>/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript">

$(function (){
	autoResize();
	var selectUrl="<%=contextPath %>/preprocess-PlaneInfo-listSourceSel.action";
	$.ajax({
			url: selectUrl,
			type: 'POST',
			dataType: 'json',
			error: function(){
				alert('渠道列表请求出错');
			},
			success: function(data){
				$('#attachHbaseKeyID').html('');
				$('#attachHbaseKeyID').append('<option value="">请选择</option>' );
				$.each(data.listSource, function(idx, e){
					$('#attachHbaseKeyID').append('<option value='+e.hbaseKey+'>'+e.name+'('+e.hbaseKey+')'+'</option>' );
				});
				loadData();
			}
			
		});

	var selectUrl1="<%=contextPath %>/airlinemanagement-TaskTemplateConfig-listFdcPort.action";
	$.ajax({
			url: selectUrl1,
			type: 'POST',
			dataType: 'json',
			error: function(){
				alert('城市列表请求出错');
			},
			success: function(data){
				$('#fromCityID').html('');
				$('#toCityID').html('');
				$('#fromCityID').append('<option value="">请选择</option>' );
				$('#toCityID').append('<option value="">请选择</option>' );
				$.each(data.Rows, function(idx, e){
					$('#fromCityID').append('<option value='+e.code+'>'+e.cityName+'('+e.code+')'+'</option>' );
					$('#toCityID').append('<option value='+e.code+'>'+e.cityName+'('+e.code+')'+'</option>' );
				});
				loadData();
			}
			
		});
});

function saveDataAction(){
	var url = '<%=contextPath %>/airlinemanagement-TaskTemplateConfig-addFun.action';
   //form validate
   if(!Validator.Validate(document.getElementById("dataForm"),3))return;
   Koala.ajax({
		type : 'POST',
		url: url,
		dataType:'json',
		data:$("#dataForm").serialize(),
		success: function(json){
			if(json && json.result){
			 parent.gridManager.loadData();
			 parent._dialog.close();
			 if(json.templateId) modifyAssignDay(json.templateId);
			}
		}
	});
}

//修改规则
function modifyAssignDay(id){
	var url = "airlinemanagement-TaskTemplateConfig-modifyAssignDay.action?id="+id;
	_dialog = jQuery.ligerDialog.open({
	    title: '编辑',
	    url:url,
	    isResize: true, width: 550, height: 550, isHidden: false
 });
}

function autoResize(){
	var _form = $("#form_table");
	var width = 550;
	var height = _form.height() + 100;
	if(_form.hasClass('form4column')){
		width = 760;
	}else if(_form.hasClass('form2column')){
		width = 550;
	}
	if(height<240)height = 240;
	try {
		$(parent.document).find("div.l-dialog-body:last").height(height).width(width);
		$(parent.document).find('div.l-dialog-content:last').height(height-5);
	} catch (e) {}
}
</script>
</head>
<body>
<div class="form_body">

  	<form id="dataForm" name="dataForm">
	  	<table id="form_table" border="0" cellpadding="0" cellspacing="0" class="form2column">
	           <tr>
	  			<td class="label">抓取渠道:</td>
	  			<td>
              		<select name="templateVO.attachHbaseKey"  id="attachHbaseKeyID" class="select-common">
		  			<option value="">请选择</option>
					</select> 
	  			</td>
	  			<td class="label">抓取状态:</td>
	  			<td>
                <select name="templateVO.status" class="select-common" id="statusID" >
		  			<option value="0">不可用</option>
		  			<option value="1" selected="selected">正常</option>
		  			<option value="2">废弃</option>
		  		</select>
	  			</td>
	  			</tr>
	  			<tr>
	  			<td class="label"> 出发城市:</td>
	  			<td>
              		<select name="templateVO.fromCity"  id="fromCityID" class="select-common">
		  			<option value="">请选择</option>
					</select> 
	  			</td>
	  			<td class="label"> 到达城市:</td>
	  			<td>
              		<select name="templateVO.toCity"  id="toCityID" class="select-common">
		  			<option value="">请选择</option>
					</select> 
	  			</td>
	  			</tr>
	           <tr>
	  			<td class="label">抓取国际:</td>
	  			<td>
                <select name="templateVO.isInternational" class="select-common" id="isInternationalID" >
		  			<option value="0">否</option>
		  			<option value="1">是</option>
		  		</select>
	  			</td>
	  			<td class="label"> 抓取往返:</td>
	  			<td>
                <select name="templateVO.isReturn" class="select-common" id="isReturnID" >
		  			<option value="0">否</option>
		  			<option value="1">是</option>
		  		</select>
	  			</td>
	  			</tr>
	           <tr>
	  			<td class="label">抓取周期(分钟):</td>
	  			<td>
               <input name="templateVO.frequency" class="input-common" type="text"  id="frequencyID" value="1440"/>
	  			</td>
	  			<td class="label">下次抓取时间:</td>
	  			<td>
               <input name="templateVO.nextGrabTime" class="input-common" type="text"  id="nextGrabTimeID" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:00:00'})" />
	  			</td>
	  			</tr>
	           <tr>
	  			<td class="label">抓取优先级:</td>
	  			<td>
               <input name="templateVO.priority" class="input-common" type="text"  id="priorityID" value="8"/>
	  			</td>
	  			<td class="label">回程范围:</td>
	  			<td>
               <input name="templateVO.returnDateScope" class="input-common" type="text"  id="returnDateScopeID" value="3"/>
	  			</td>
	  			</tr>
	           <tr>
	  			<td class="label">开始范围:</td>
	  			<td>
               <input name="templateVO.grabScopeBegin" class="input-common" type="text"  id="grabScopeBeginID" value="0"/>
	  			</td>
	  			<td class="label">结束范围:</td>
	  			<td>
               <input name="templateVO.grabScopeEnd" class="input-common" type="text"  id="grabScopeEndID" value="30" />
	  			</td>
	  			</tr>
	           <tr>
	  			<td class="label">生效日期:</td>
	  			<td>
               <input name="templateVO.validityFrom" class="input-common" type="text"  id="validityFromID" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="2015-01-01"/>
	  			</td>
	  			<td class="label">失效日期:</td>
	  			<td>
               <input name="templateVO.validityTo" class="input-common" type="text"  id="validityToID" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="2099-12-31"/>
	  			</td>
	  			</tr>
	  </table>
	  <div class="form_button">
        <input id="searchButton" type="button" class="btn-normal" onclick="saveDataAction()" value="保存" />
	  	 &nbsp;&nbsp;
	  	<input type="reset" class="btn-normal" value="重置" />
     </div>
  	</form>
</div>
</body>
</html>
